<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$setting=$this->plugin_setting('setting');
$return['setting'] = $setting;
$return['adv']=$setting['hdps'];
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	$postdata=get_postdata();
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
    $fields=array('id','title','mobile','logo','name','price','junjia','mianji','type','address');
    $orderby='paixu desc';
	$total='';
	$return['list']=pdo_getslice('jy_cmshouse_list',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['lat_lng']=json_decode($v['lat_lng'],true);
		$v['juli']=cfc('tools')->getdistance($postdata['lng'],$postdata['lat'],$v['lat_lng']['lng'],$v['lat_lng']['lat']);
		$v['juli']=intval($v['juli']/1000);
		$_SESSION['juli'][$id]=$v['juli'];
	}
	$_SESSION['houselist']=$return['list'];
	
	if($postdata['keyword']=='juli'){
		paixu($_SESSION['houselist'],'juli','asc');
		$return['list']=$_SESSION['houselist'];
	}
	exi($return);
	}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if($id){
		exi('请选择房产','error','/list/');
	}
	$return['detail']=pdo_get('jy_cmshouse_list',array('id'=>$id));
	exi($return);
}

?>